import { createContext, useContext } from "react";

const CesiumContext = createContext(null);

export const CesiumProvider = ({ children, viewer }) => (
  <CesiumContext.Provider value={viewer}>{children}</CesiumContext.Provider>
);

export const useCesium = () => {
  const viewer = useContext(CesiumContext);
  if (!viewer) {
    console.error("Cesium viewer is not initialized.");
  }
  return viewer;
};
